﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Tayninh2011
{
    public sealed partial class FrmMainMain : RootForm
    {
        //frmCash frmCash = frmCash.CallMe;
        //FrmMap frmMap = FrmMap.FormMap;
        TnToolTips.TnToolTipsCustom toolTip = new TnToolTips.TnToolTipsCustom();

        #region Make it seleton
        private static readonly FrmMainMain formMainMain = new FrmMainMain();

        private FrmMainMain()
        {
            InitializeComponent();
            initToolTips();
        }

        private void initToolTips()
        {
            toolTip.AutomaticDelay = 300;
            toolTip.IsBalloon = true;
            toolTip.UseAnimation = true;
            toolTip.SetToolTip(pbxCash, "Tính giá đất");
            toolTip.SetToolTip(pbxMap, "Bản đồ");
        }
  
        public static FrmMainMain CallMe
        {
            get { return formMainMain; }
        }

        public new void Show()
        {
            if (isShown)
            {
                base.Show();
            }
            else
            {
                base.Show();
                isShown = true;
            }
        }
        private static bool isShown = false;
        static FrmMainMain()
        {

            formMainMain.FormClosing += new FormClosingEventHandler(FrmMainMain_FormClosing);

        }
        private static void FrmMainMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            isShown = false;
            formMainMain.Hide();
            Application.ExitThread();
            Application.Exit();
        }
        #endregion

        private void pbxMap_Click(object sender, EventArgs e)
        {
            FrmMap frmMap = FrmMap.FormMap;
            frmMap.Show();
            frmMap.BringToFront();
            frmMap.WindowState = FormWindowState.Normal;
            frmMap.SetDesktopLocation((Screen.PrimaryScreen.Bounds.Width - frmMap.Width) / 2, (Screen.PrimaryScreen.Bounds.Height - frmMap.Height) / 2);
        }

        private void pbxCash_Click(object sender, EventArgs e)
        {
            FrmCash frmCash = FrmCash.CallMe;
            frmCash.Show();
            frmCash.BringToFront();
            //frmCash.TopMost = true;
            frmCash.WindowState = FormWindowState.Normal;
            frmCash.SetDesktopLocation((Screen.PrimaryScreen.Bounds.Width - frmCash.Width) / 2, (Screen.PrimaryScreen.Bounds.Height - frmCash.Height) / 2);
        }

        private void pbxCash_MouseHover(object sender, EventArgs e)
        {
            //pbxCash.BorderStyle = BorderStyle.FixedSingle;
        }

        private void pbxCash_MouseLeave(object sender, EventArgs e)
        {
            pbxCash.BorderStyle = BorderStyle.None;
        }

        private void pbxCash_MouseDown(object sender, MouseEventArgs e)
        {
            pbxCash.BorderStyle = BorderStyle.Fixed3D;
        }

        private void pbxCash_MouseUp(object sender, MouseEventArgs e)
        {
            pbxCash.BorderStyle = BorderStyle.None;
        }
    }
}
